package com.bgds.sys.api.feign;

import com.bgds.sys.api.bean.mars.bo.DtUserBo;
import com.bgds.sys.api.bean.mars.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @Author: warm
 * @Description: 德通接口
 * @Date: 2020/7/27 14:39
 * @Version: 1.0
 */
@FeignClient(name = "marsFeignClient", url = "${detong.url}")
public interface MarsFeignClient {

    /**
     * 德通厂家，认证用户获取token方法
     *
     * @param dtUserBo
     * @return
     */

    @PostMapping("/auth")
    Map<String, String> auth(@RequestBody DtUserBo dtUserBo);


    /**
     * 根据 id 获取节点详情
     *
     * @param id
     * @param token
     * @return
     */
    @GetMapping("/node/{id}")
    NodeDto listNode(@PathVariable(name = "id") String id, @RequestHeader(value = "Authorization") String token);


    /**
     * 获取德通设备树节点
     *
     * @param token
     * @return
     */
    @GetMapping("/tree")
    List<TreeDto> tree(@RequestHeader(value = "Authorization") String token);

    /**
     * 请求厂家历史数据
     *
     * @param id
     * @param code
     * @param startTime
     * @param endTime
     * @param pageIndex
     * @param pageSize
     * @param token
     * @return
     */
    @GetMapping("/node/{id}/{code}/history_data")
    List<TrendDataDto> getHisData(@PathVariable(name = "id") String id,
                                  @PathVariable(name = "code") Integer code,
                                  @RequestParam(value = "start_time", required = false) String startTime,
                                  @RequestParam(value = "end_time", required = false) String endTime,
                                  @RequestParam(value = "page_index", required = false) Integer pageIndex,
                                  @RequestParam(value = "page_size", required = false) Integer pageSize,
                                  @RequestHeader(value = "Authorization") String token);

    /**
     * 请求厂家历史数据量
     *
     * @param id
     * @param code
     * @param startTime
     * @param endTime
     * @param token
     * @return
     */
    @GetMapping("/node/{id}/{code}/history_data/count")
    Integer getHisCount(@PathVariable(name = "id") String id,
                        @PathVariable(name = "code") Integer code,
                        @RequestParam(value = "start_time", required = false) String startTime,
                        @RequestParam(value = "end_time", required = false) String endTime,
                        @RequestHeader(value = "Authorization") String token);


    /**
     * 调用厂家api 查询波形数据
     *
     * @param id
     * @param code
     * @param time
     * @param token
     * @return
     */
    @GetMapping("/node/{id}/{code}/wave_data/{time}")
    WaveDataDto getWaveData(@PathVariable(name = "id") String id,
                            @PathVariable(name = "code") Integer code,
                            @PathVariable(name = "time") String time,
                            @RequestHeader(value = "Authorization") String token);

    @GetMapping("/node/{id}/{code}/wave_data/{time}")
    byte[] getWaveData(@PathVariable(name = "id") String id,
                       @PathVariable(name = "code") Integer code,
                       @PathVariable(name = "time") String time,
                       @RequestHeader(value = "Authorization") String token,
                       @RequestHeader(value = "Accept") String contentType,
                       @RequestHeader(value = "Accept-Language") String language,
                       @RequestHeader(value = "Accept-Encoding") String acceptEncoding);

    /**
     * 调用厂家api 查询频谱数据
     *
     * @param id
     * @param code
     * @param time
     * @param token
     * @return
     */
    @GetMapping("/node/{id}/{code}/spectrum_data/{time}")
    byte[] getSpectrumData(@PathVariable(name = "id") String id,
                           @PathVariable(name = "code") Integer code,
                           @PathVariable(name = "time") String time,
                           @RequestHeader(value = "Authorization") String token,
                           @RequestHeader(value = "Accept") String contentType,
                           @RequestHeader(value = "Accept-Language") String language,
                           @RequestHeader(value = "Accept-Encoding") String acceptEncoding
    );

    @GetMapping("/node/{id}/{code}/spectrum_data/{time}")
    WaveDataDto getSpectrumData1(@PathVariable(name = "id") String id,
                                 @PathVariable(name = "code") Integer code,
                                 @PathVariable(name = "time") String time,
                                 @RequestHeader(value = "Authorization") String token);


    /**
     * 调用厂家api 查询倒谱数据
     *
     * @param id
     * @param code
     * @param time
     * @param token
     * @return
     */
    @GetMapping("/node/{id}/{code}/cepstrum_data/{time}")
    WaveDataDto getCepstrumData(@PathVariable(name = "id") String id,
                                @PathVariable(name = "code") Integer code,
                                @PathVariable(name = "time") String time,
                                @RequestHeader(value = "Authorization") String token);

    @GetMapping("/node/{id}/{code}/cepstrum_data/{time}")
    byte[] getCepstrumData(@PathVariable(name = "id") String id,
                           @PathVariable(name = "code") Integer code,
                           @PathVariable(name = "time") String time,
                           @RequestHeader(value = "Authorization") String token,
                           @RequestHeader(value = "Accept") String contentType,
                           @RequestHeader(value = "Accept-Language") String language,
                           @RequestHeader(value = "Accept-Encoding") String acceptEncoding);

    /**
     * 调用厂家api 查询包络数据
     *
     * @param id
     * @param code
     * @param time
     * @param centerFreq
     * @param filterWidth
     * @param token
     * @return
     */
    @GetMapping("/node/{id}/{code}/envelope_data/{time}/{centerFreq}/{filterWidth}")
    WaveDataDto getEnvelopeData(@PathVariable(name = "id") String id,
                                @PathVariable(name = "code") Integer code,
                                @PathVariable(name = "time") String time,
                                @PathVariable(name = "centerFreq") Double centerFreq,
                                @PathVariable(name = "filterWidth") Double filterWidth,
                                @RequestHeader(value = "Authorization") String token);

    @GetMapping("/node/{id}/{code}/envelope_data/{time}/{centerFreq}/{filterWidth}")
    byte[] getEnvelopeData(@PathVariable(name = "id") String id,
                           @PathVariable(name = "code") Integer code,
                           @PathVariable(name = "time") String time,
                           @PathVariable(name = "centerFreq") Double centerFreq,
                           @PathVariable(name = "filterWidth") Double filterWidth,
                           @RequestHeader(value = "Authorization") String token,
                           @RequestHeader(value = "Accept") String contentType,
                           @RequestHeader(value = "Accept-Language") String language,
                           @RequestHeader(value = "Accept-Encoding") String acceptEncoding);


    /**
     * 获取节点指标最新值
     *
     * @param id
     * @param code
     * @param token
     * @return
     */
    @GetMapping("/node/{id}/{code}/latest_data")
    List<DataTimeSerise> getLastData(
            @PathVariable(name = "id") String id,
            @PathVariable(name = "code") Integer code,
            @RequestHeader(value = "Authorization") String token
    );

    /**
     * 获取分页报警
     *
     * @param detailCount 详情数量（不填则默认为3）
     * @param pageIndex   页码（>1）
     * @param pageSize    每页数量（1~100000000）
     * @param token
     * @return
     */
    @GetMapping("/alarm")
    List<AlarmEventDto> getAlarm(
            @RequestParam(value = "detail_count", required = false) Integer detailCount,
            @RequestParam(value = "page_index") Integer pageIndex,
            @RequestParam(value = "page_size") Integer pageSize,
            @RequestHeader(value = "Authorization") String token
    );

    /**
     * 获取报警数量
     *
     * @param token
     * @return
     */
    @GetMapping("/alarm/count")
    Integer getAlarmCount(
            @RequestHeader(value = "Authorization") String token
    );

    /**
     * 获取报警详情
     *
     * @param alarmId
     * @param pageIndex
     * @param pageSize
     * @param token
     * @return
     */
    @GetMapping("/alarm/{alarmId}/detail")
    List<AlarmEventDetails> getAlarmDetails(
            @PathVariable(value = "alarmId") Integer alarmId,
            @RequestParam(value = "page_index") Integer pageIndex,
            @RequestParam(value = "page_size") Integer pageSize,
            @RequestHeader(value = "Authorization") String token
    );

}